﻿using System;
using System.Net;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
using System.Collections.ObjectModel;
using System.Collections.Generic;

namespace ImplicitDataTemplateTester
{
    public class MainViewModel : INotifyPropertyChanged
    {
        private readonly ObservableCollection<Shape> _shapes;
        private Shape _selectedShape;

        public MainViewModel()
        {
            _shapes = new ObservableCollection<Shape>
            {
                new Circle(), new Rectangle(), new Triangle()
            };

            SelectedShape = _shapes.First();
        }

        public IEnumerable<Shape> Shapes
        {
            get { return _shapes; }
        }

        public Shape SelectedShape
        {
            get { return _selectedShape; }
            set
            {
                if (_selectedShape != value)
                {
                    _selectedShape = value;
                    NotifyPropertyChanged("SelectedShape");
                }
            }
        }

        #region INotifyPropertyChanged Members

        private void NotifyPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }
}
